package com.pro.controller;

import com.pro.pojo.JsActicleCategroy;
import com.pro.pojo.JsSum;
import com.pro.pojo.JsonData;
import com.pro.service.JsActicleCategroyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName:JsActicleCategroyController
 * Package:com.pro.controller
 * Description:
 *
 * @Date:2022/1/7 15:25
 * @Author: ZPT
 */
@RestController
@RequestMapping("/acticleCategroy")
public class JsActicleCategroyController {

    @Autowired
    private JsActicleCategroyService acticleCategroyService;
    /**
     *
     * @author ZPT
     * @date 2022/1/7 15:06
     * @content :文章分类数据
     */
    @RequestMapping("/getTree")
    public JsonData getTree(){
        List<JsActicleCategroy> tree = acticleCategroyService.getTree();
        return tree!=null?JsonData.buildSuccess(tree):JsonData.buildError("服务端错误");
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/7 15:44
     * @content :添加文章分类
     */
    @RequestMapping("/addActicleCategroy")
    public JsonData addActicleCategroy(JsActicleCategroy jsActicleCategroy){
        Boolean aBoolean = acticleCategroyService.addActicleCategroy(jsActicleCategroy);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/7 15:44
     * @content :修改文章分类
     */
    @RequestMapping("/updateActicleCategroy")
    public JsonData updateActicleCategroy(JsActicleCategroy jsActicleCategroy){
        Boolean aBoolean = acticleCategroyService.updateActicleCategroy(jsActicleCategroy);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/7 15:44
     * @content :删除文章分类
     */
    @RequestMapping("/deleteActicleCategroy")
    public JsonData deleteActicleCategroy(Integer acticleCategroyId){
        Boolean aBoolean = acticleCategroyService.deleteActicleCategroy(acticleCategroyId);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/19 16:32
     * @content :微圈点赞、分享、点击量
     */
    @RequestMapping("/getActicleSum")
    public JsonData getActicleSum(String field){
        List<JsSum> sumList = acticleCategroyService.getActicleSum(field);
        return sumList!=null?JsonData.buildSuccess(sumList):JsonData.buildError("服务端错误");
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/19 17:03
     * @content :微圈的收藏量
     */
    @RequestMapping("/getCollectArcticleSum")
   public JsonData getCollectArcticleSum(Integer collectionType){
       List<JsSum> collectArcticleSum = acticleCategroyService.getCollectArcticleSum(collectionType);
       return collectArcticleSum!=null?JsonData.buildSuccess(collectArcticleSum):JsonData.buildError("服务端错误");
   }
}
